﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Touch2Like.Model;
using Touch2Like.DAL;
using Touch2Like.SharedLibrary;


namespace Touch2Like.Web.Admin
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btn_Login_Click(object sender, EventArgs e)
        {
            AdminUserDAL admin = new AdminUserDAL();
            AdminUserInfo info = admin.GetByUsername(tb_UserName.Text.Trim());

            if (info != null && info.Password == Utility.Encryption.Encrypt(tb_Password.Text.Trim()))
            {
                WebUtility.AdminUsername = info.UserName;

                Response.Redirect("Index.aspx");
            }
            else
            {
                tb_UserName.Text = "";
                //tb_Password.Text = "";

                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('Invalid Username or Password');</script>");
            }
        }
    }
}